/**
 * 
 */
package com.wubo.bm.common.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wubo.bm.common.constant.ResponseType;
import com.wubo.bm.common.entity.FeedBack;
import com.wubo.bm.common.service.IFeedBackService;
import com.wubo.bm.exception.BackendException;
import com.wubo.spring.hibernate.BaseHibernateDao;
import com.wubo.spring.hibernate.EntityService;

/**
 * @author WuBo
 * @CreateDate 2012-2-22 下午03:08:08
 */
@Service
public class FeedBackService extends EntityService<FeedBack> implements IFeedBackService {
	@Autowired
	public FeedBackService(BaseHibernateDao dao){
		super.setDao(dao);
	}
	
	public void delete(FeedBack feedBack){
		long sum = super.queryForLong("select count(r.id) from Response r where r.type = "+ResponseType.FEEDBACK+" and r.typeId = "+feedBack.getId());
		if(sum > 0){
			throw new BackendException("不能删除已有回复的记录");
		}
		getDao().delete(feedBack);
	}
	
}
